package code.c02_list.linkList;

import code.c02_list.linkList.LinkListClass;
import code.c02_list.clinkList.LinkNode;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/9/18 18:57
 * @package code.c02_list.classwork.examples
 * @description
 *
 */

public class Exam_2_14 {
    public static LinkListClass<Integer> comb(LinkListClass<Integer> A,LinkListClass<Integer> B){
        LinkListClass<Integer> C = new LinkListClass<>();
        LinkNode<Integer> p = A.head.next;
        LinkNode<Integer> q = B.head.next;
        LinkNode<Integer> t = C.head;

        while (p!=null && q != null){
            t.next = p;
            t = p;
            p = p.next;
            t.next = q;
            t = q;
            q = q.next;
        }

        t.next = null;

        if (p!=null){
            t.next = p;
        }
        if (q != null){
            t.next = q;
        }

        return C;
    }
}
